import { createSlice } from "@reduxjs/toolkit";
import axios from "axios";

const billStore = createSlice({
  name: "billStore",
  initialState: {
    billsList: [],
    
  },
  reducers: {
    addBill: (state, action) => {
      state.billsList = action.payload
    }, 
  }
})

const {addBill } = billStore.actions;

const getBillList = ()=>{
  return async (dispatch)=>{
    const res = await axios.get('http://localhost:3004/ka'); 
   console.log(res.data,99999);
   
    dispatch(addBill(res.data));
  }
}


export { addBill ,getBillList }
export default billStore.reducer;